#ifndef ALGO_PRM_H
#define ALGO_PRM_H

#include "algohub_export.h"
#include "algohub_common_type.h"
#include <vector>
#include <string>

namespace algo
{
    class AlgoPRMPrivate;
    class ALGOHUB_EXPORT AlgoPRM final
    {
    public:
        AlgoPRM();
        ~AlgoPRM();

        /**
         * @brief Offline phase: Builds the roadmap graph based on the environment.
         * This is a potentially slow operation and should be done once per environment.
         * @param taskConfig Defines the boundaries and constraint zones (obstacles, restricted areas).
         * @param terrain 2D matrix of depth data.
         * @return 0 on success, non-zero on failure.
         */
        int buildRoadmap(const algobase::TaskConfig& taskConfig, const std::vector<std::vector<double>>& terrain);

        /**
         * @brief Online phase: Quickly queries the pre-built roadmap to find paths.
         * This method is designed to be very fast. It requires buildRoadmap to have been called successfully first.
         * @param taskConfig Defines the start, end, and mandatory zones for this specific query.
         * @param paths Output vector to store the large batch of generated paths.
         * @return 0 on success, non-zero on failure.
         */
        int findPaths(const algobase::TaskConfig& taskConfig, algobase::Paths& paths);

        /**
         * @brief Saves the built roadmap to a file for later use.
         * @param filepath The path to the file where the roadmap will be saved.
         * @return 0 on success, non-zero on failure.
         */
        int saveRoadmap(const std::string& filepath) const;

        /**
         * @brief Loads a pre-built roadmap from a file, skipping the build phase.
         * @param filepath The path to the file from which the roadmap will be loaded.
         * @return 0 on success, non-zero on failure.
         */
        int loadRoadmap(const std::string& filepath);

    private:
        AlgoPRMPrivate* d;
    };
}

#endif // ALGO_PRM_H